import Vue from 'vue'
import VueRouter from "vue-router";

Vue.use(VueRouter)

const routes = [
    {
        path: '/',
        component: () => import('@/views/layout/index.vue'),
        redirect: '/home',
        children: [
            {
                path: '/home',
                component: () => import('@/views/home/index.vue'),
            },
            {
                path: '/question',
                component: () => import('@/views/question/index.vue'),
            },
            {
                path: '/video',
                component: () => import('@/views/video/index.vue'),
            },
            {
                path: '/user',
                component: () => import('@/views/user/index.vue'),
            }
        ]
    },
    {
        path: '/user/profile',
        component: () => import('@/views/user/profile.vue'),
    },
    {
        path: '/user/chat',
        component: () => import('@/views/user/chat.vue'),
    },
    {
        path: '/login',
        name: 'login',
        component: () => import('@/views/user/login'),
    },
    {
        // 当前路由有参数，名称为aid
        path: '/article/:aid',
        name: 'article',
        component: () => import('@/views/article/index.vue'),
    },
    {
        path: '/search',
        component: () => import('@/views/search/index.vue'),
    },
    {   
        // 当路由通过：设置，有参数，名称为keyword
        path: '/search/result/:keyword',
        component: () => import('@/views/search/result.vue'),
    }
]

const router = new VueRouter({
    routes
})

export default router